<?php
require $_SERVER['DOCUMENT_ROOT'].'/../_core/common.php';

$msg = array();

//权限验证
if( Role::init() == false ){
	$msg['error'] = false;
	$msg['string'] = '权限不足！';
	$myjson = json_encode($msg); 
	echo $myjson; 
	exit;
}

$db = new DB('news');

$id = isset($_POST['id']) ? h($_POST['id']) : '';

$news_sql = 'select category_id,title_id,title from news where title_id="'.$id.'" and is_del=2';
$news_rs = $db->query($news_sql)->getOne();

if( $news_rs['title_id'] == '' ){//id不存在
	$msg['error'] = false;
	$msg['string'] = '参数有误！';
}else{
	//更新is_del字段
	$data=array('is_del'=>3,'edit_uid'=>Sessions::get('uid'),'updated'=>time());
	$db->table('news')->where('title_id="'.$id.'"')->update($data)->run();
	$msg['error'] = true;
	$msg['string'] = '成功彻底删除新闻['.$news_rs['title_id'].']《'.$news_rs['title'].'》!';
	
	//记录动作日志
	Log::logs_articles($news_rs['category_id'], 8, $news_rs['title_id'], $news_rs['title']);

}
$myjson = json_encode($msg); 
echo $myjson; 
exit;